package com.wondertek.poms.core.service.impl;

import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.core.service.IMediaFileService;
import com.wondertek.poms.dao.po.DisplayFile;
import com.wondertek.poms.dao.po.MediaFile;
import com.wondertek.poms.dao.repo.IMediaFileDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import javax.transaction.Transactional;

@Service
public class MediaFileServiceImpl extends ServiceImpl<MediaFile, Long> implements IMediaFileService {

    @Autowired
    private IMediaFileDao mediaFileDao;

    @Override
    public MediaFile deleteLogic(Long id) {
        return null;
    }

    @Override
    public MediaFile merge(MediaFile model) {
        return null;
    }

    @Override
    @Transactional
    public void deleteByContentId(String contentId) {
        mediaFileDao.deleteByContentId(contentId);
    }

    @Override
    public List<MediaFile> findByContentId(String contentId) {
        return mediaFileDao.findAllByContentId(contentId);
    }

    @Override
    public List<MediaFile> findByContentIdAndOprCode(String contentId, String oprCode) {
        return mediaFileDao.findAllByContentIdAndOprCode(contentId,oprCode);
    }

    @Override
    public MediaFile getByContentIdAndMediaFileId(String contentId, String mediaFileId) {
        List<MediaFile> list=mediaFileDao.findAllByContentIdAndMediaFileID(contentId,mediaFileId);
        if (list != null && list.size() > 0) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public List<MediaFile> findListByContent(String contentId) {
        return mediaFileDao.findList(contentId);
    }
}
